// pages/mine/attention/attention.js
import Notify from '@vant/weapp/notify/notify';
const app = getApp()
Page({
	/**
	 * 页面的初始数据
	 */
	data: {
		userList:[],
    user:{},
    loadModal:true
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {
		this.setData({
			user:wx.getStorageSync('user')
		})
		this.getAll()
	},
	getAll(){
		app.request({
			url: app.globalData.apiUrl + "/follow/attention",
			method: 'GET',
		}).then(res => {
			if (res.statusCode == 200) {
				this.setData({
          userList:res.data.data,
          loadModal:false
				})
				console.log(res.data.data)
			} else {
        this.setData({
          loadModal:false
        })
				Notify('服务错误，稍后重试');
			}
		})
	},
	//取关
	cancel(e) {
    var json = JSON.stringify({
      userId: this.data.user.id,
      follow: e.target.dataset.id
    })
    app.request({
      url: app.globalData.apiUrl + "/follow/" + json,
      method: 'DELETE',
    }).then(res => {
      if (res.statusCode == 200) {
        this.setData({
          followed: false
        })
				Notify('通知内容');
				this.getAll()
      } else {
        Notify('服务错误，稍后重试');
      }
    })
	},
})